<template>
  <a-modal
    :maskClosable="false"
    :title="title"
    :width="width"
    placement="right"
    :closable="closable"
    @cancel="handleCancel"
    @ok="handleOk"
    :cancelText="cancelText"
    :visible="visible"
    :destroyOnClose="true"
  >
    <template v-if="!showFooterBtn" slot="footer">
      <a-button style="margin-bottom: 0; float: none" @click="handleCancel">关闭</a-button>
    </template>
    <!-- 展示内容的区域 -->
    <!-- 并不做任何关联操作，插槽内的内容的操作都通过父组件来控制 -->
    <slot></slot>
  </a-modal>
</template>
<script>
export default {
  name: 'simpleModal',
  components: {},
  props: {
    title: {
      type: String,
      default: '新增',
    },
    width: {
      type: Number,
      default: 1000,
    },
    showSaveBtn: {
      type: Boolean,
      default: true,
    },
    buttonDisable: {
      type: Boolean,
      default: false,
    },
    cancelText: {
      type: String,
    },
    closable: {
      type: Boolean,
      default: false,
    },
    showFooterBtn: {
      type: Boolean,
      default: true,
    },
  },
  data() {
    return {
      visible: false,
    }
  },
  methods: {
    close() {
      this.visible = false
    },
    submitCallback(type, record) {},
    handleOk() {
      this.$emit('clickSubmit')
      // 关闭弹窗由父组件调用，父组件接口调用成功后关闭弹窗
    },
    handleCancel() {
      this.close()
    },
  },
}
</script>

<style lang="less" scoped>
/** Button按钮间距 */
.ant-btn {
  margin-left: 30px;
  margin-bottom: 30px;
  float: right;
}
.drawer-footer {
  position: absolute;
  bottom: -8px;
  width: 100%;
  border-top: 1px solid #e8e8e8;
  padding: 10px 16px;
  text-align: right;
  left: 0;
  background: #fff;
  border-radius: 0 0 2px 2px;
  z-index: 9999999;
}
</style>
